unit MenuF;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ShellApi;

type
  TLicenciaForm = class(TForm)
    GenerarBitBtn: TBitBtn;
    LicenciaMemo: TMemo;
    CopiarBitBtn: TBitBtn;
    EnviarPorEmailBitBtn: TBitBtn;
    NombresEdit: TEdit;
    ApellidosEdit: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    DNIEdit: TEdit;
    procedure GenerarBitBtnClick(Sender: TObject);
    procedure CopiarBitBtnClick(Sender: TObject);
    procedure EnviarPorEmailBitBtnClick(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  LicenciaForm: TLicenciaForm;

implementation

{$R *.dfm}

function GetVolumeID(DriveChar: string): String;
var
   MaxFileNameLength, VolFlags, SerNum: DWord;
begin
   if GetVolumeInformation(PChar(DriveChar + '\'), nil, 0,
      @SerNum, MaxFileNameLength, VolFlags, nil, 0)
   then
   begin
     Result := IntToHex(SerNum,8);
     Insert('-', Result, 5);
   end
   else
       Result := '';
end;



procedure TLicenciaForm.CopiarBitBtnClick(Sender: TObject);
begin
if (ApellidosEdit.Text <> '') and (NombresEdit.Text <> '') and (DNIEdit.Text <> '') then
begin
GenerarBitBtn.Click;
LicenciaMemo.SelectAll;
LicenciaMemo.CopyToClipboard;
end  else
 begin
 ShowMessage('Por Favor Complete todos los Campos');
 ApellidosEdit.SetFocus
 end;
end;

procedure TLicenciaForm.EnviarPorEmailBitBtnClick(Sender: TObject);
var
  wideChars : array[0..999] of WideChar;
  myString  : String;
begin
if (ApellidosEdit.Text <> '') and (NombresEdit.Text <> '') and (DNIEdit.Text <> '') then
begin
GenerarBitBtn.Click;
LicenciaMemo.SelectAll;
LicenciaMemo.CopyToClipboard;
myString:=    'mailto:ventas@civeloo.com.ar'+
              '?Subject=Registro de Licencia de '+ApellidosEdit.Text+' '+NombresEdit.Text+' DNI: '+DNIEdit.Text+
              '&Body=' + LicenciaMemo.Text;
StringToWideChar(myString, wideChars, 256);
ShellExecute(Self.Handle, nil,
             wideChars,
             nil, nil, SW_NORMAL);
end  else
 begin
 ShowMessage('Por Favor Complete todos los Campos');
 ApellidosEdit.SetFocus
 end;
end;

procedure TLicenciaForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
 if Key = #13 then                          { if it's an enter key }
 begin
      Key := #0;                                 { eat enter key }
      Perform(WM_NEXTDLGCTL, 0, 0);              { move to next control }
  end;
end;

procedure TLicenciaForm.GenerarBitBtnClick(Sender: TObject);
begin
if (ApellidosEdit.Text <> '') and (NombresEdit.Text <> '') and (DNIEdit.Text <> '') then
 LicenciaMemo.Text := ApellidosEdit.Text+NombresEdit.Text+DNIEdit.Text+'=Q2T-94-RTWMKPQ9VDFV}4GQG]'+GetVolumeId(ExtractFileDrive(Application.ExeName))+'57WPDRDCT9-HJFF2ER'
 else
 begin
 ShowMessage('Por Favor Complete todos los Campos');
 ApellidosEdit.SetFocus
 end;
end;

end.
